<?php

class ReportesController extends AppController {

    var $uses = array('ControlIngreso');

    function param_reporte_ingresos() {

    }

    function reporte_ingresos($mes=null, $anio=null, $imprimir=null) {
        $this->layout = "default_1";
        $this->ControlIngreso->recursive = 1;
        $ingresos = $this->ControlIngreso->find('all',
                        array('conditions' => array(
                                'month(hora_ingreso)' => $mes,
                                'year(hora_ingreso)' => $anio
                        )));
        $this->set(compact('ingresos'));
    }

    function imprimir_reporte($nombre) {
        $this->layout = 'ajax';
        if (isset($this->data['Reporte']['paramreporte'])) {
            require_once(VIEWS . 'reportes/html2pdf/html2pdf.class.php');
            $html2pdf = new HTML2PDF('P', 'A4', 'fr');
            $html2pdf->WriteHTML($this->data['Reporte']['paramreporte'], isset($_GET['vuehtml']));
            $html2pdf->Output($this->params['pass'][0] . '.pdf', 'D');
        }

        $e = explode('/', $this->data['Reporte']['quien']);
        $url = '';
        for ($i = 2; $i < count($e); $i++) {
            $url = $url . '/' . $e[$i];
        }
        $this->redirect($url);
    }

    function beforeFilter() {
        parent::beforeFilter();
        $this->Auth->autoRedirect = false;
        //$this->Auth->allowedActions = array('*');//cuando no haya ninguno
    }

}
?>
